#include "Log.hpp"
#include "Socket.hpp"
#include "TcpServer.hpp"
#include "ServerCal.hpp"
#include <iostream>
#include <memory>
#include <functional>

extern Log lg;


void Usage(const std::string &proc)
{
    std::cout << "\n\r"
              << "Usage:" << proc << " port" << std::endl;
}

// .ServerCal port
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        Usage(argv[0]);
        exit(1);
    }
    uint16_t port = std::stoi(argv[1]);

    calc c;
    unique_ptr<TcpServer> tcpv(new TcpServer(port, std::bind(&calc::Calculator, &c,std::placeholders::_1)));
    tcpv->InitServer();
    daemon(0,0);
    tcpv->Start();

    return 0;
}